package com.leetcode.algorithm.y22.m08.w4;

/**
 * 1464. 数组中两元素的最大乘积
 * 
 * https://leetcode.cn/problems/maximum-product-of-two-elements-in-an-array/
 * 
 * @author jie.deng
 *
 */
class Question1464Solution01 {

	public int maxProduct(int[] nums) {
		int first = 0;
		int second = 0;
		for (int num : nums) {
			if (num >= first) {
				second = first;
				first = num;
			} else if (num >= second) {
				second = num;
			}
		}
		return (first - 1) * (second - 1);
	}

}